services:
  db:
    image: postgres:12.2-alpine
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - PGUSER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PW}
    restart: always
    expose:
      - 5432
    ports:
      - "5432:5432"
    volumes:
      - ./db:/var/lib/postgresql/data
    env_file:
      - stage.env
    healthcheck:
      test: ["CMD-SHELL", "pg_isready", "-U", "${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  vkbot:
    image: vkadmin-vkbot
    build:
      context: ./vkbot
    volumes:
      - ./data:/base/data
    env_file:
      - stage.env
    depends_on:
      db:
        condition: service_healthy
